package com.situ.student.controller;

import java.util.List;

import com.situ.student.entity.Student;
import com.situ.student.exception.IdNotFoundException;
import com.situ.student.exception.NameRepeatException;
import com.situ.student.service.IStudentService;
import com.situ.student.service.impl.StudentServiceImpl;

public class StudentController {
	private IStudentService studentService = new StudentServiceImpl();
	
	public boolean register(String name, int age, String gender) throws NameRepeatException {
		Student student = new Student(age, name,age,gender);
		boolean result = studentService.register(student);
		return result;
	}

	public List<Student> finaAll() {
		return studentService.findAll();
	}

	public boolean delete(int id) throws IdNotFoundException {
		Student student = new Student(id);
		return studentService.delete(student);
	}

	public boolean update(int id, String name, int age, String gender) throws IdNotFoundException {
		Student student = new Student(id, name, age, gender);
		return studentService.update(student);
	}

}
